package test.data;

import java.io.Reader;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import data.dao.I3properties;
import data.mapper.I3propertiesMapper;

public class MyBatisTest2 {
	private static SqlSessionFactory sqlSessionFactory;
	private static Reader reader; 

	static{
        try{
            reader = Resources.getResourceAsReader("data/xml/Mybatis.xml");
            sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
        }catch(Exception e){
            e.printStackTrace();
        }
	}

    public static SqlSessionFactory getSession(){
        return sqlSessionFactory;
    }
    public static void main(String[] args){
    	  SqlSession session = sqlSessionFactory.openSession();
          try {
        	  I3propertiesMapper i3propertiesMapper = session.getMapper(I3propertiesMapper.class);
        	  I3properties i3properties = i3propertiesMapper.findInfoById(1);
        	  
        	  System.out.println(i3properties);
          }catch (Exception e) {
        	 e.printStackTrace(); 
          }finally {
			session.close();
		}
		
    }
    
}
